function Toolbar(id) {

	this.setup = function() {
		var sel = null;
		var tb = $(id+'Tray');
		if (!tb) return;

		for (var i = 0; i < tb.rows.length; i++) {
			var r = tb.rows[i].cells[0];
			r.onmouseover = r.onmouseup = function() { this.className = 'clsBtnOn'; }
			r.onmousedown = function() { this.className = 'clsBtnDown'; }
			r.onmouseout = function() { this.className = 'clsBtnOff'; }
			if (tb.rows[i].id == 'idSelected')
				sel = tb.rows[i];
		}

		var up = $(id+'Up');
		var dn = $(id+'Dn');
		up.rev = dn;
		dn.rev = up;

		up.direction = 10;
		dn.direction = -10;
		up.slider = dn.slider = $(id+'Slider');
		up.container = dn.container = $(id+'Container');

		up.update = function() {
			var t = this.slider.style.top ? parseInt(this.slider.style.top, 10) : 0;
			this.className = t >= 0 ? 'scroll_no' : 'scroll_up';
		}
		dn.update = function() {
			var t = this.slider.style.top ? parseInt(this.slider.style.top, 10) : 0;
			this.className = t + this.slider.offsetHeight <= this.container.offsetHeight ? 'scroll_no' : 'scroll_dn';
		}

		up.onmouseup = dn.onmouseup = function() {
			if (this.timer) {
				ajax.send('toolbar.php?top='+this.slider.offsetTop,'');
				clearTimeout(this.timer);
				this.timer = undefined;
			}
		}

		up.scroll = dn.scroll = function() {
			var d = this.direction;
			var t = this.slider.style.top ? parseInt(this.slider.style.top, 10) + d : d;
			if ((d < 0 && this.slider.offsetHeight + t >= this.container.offsetHeight - 10) || (d > 0 && t <= 0)) {
				this.slider.style.top = t + 'px';
				this.rev.update();
			}
			else {
				this.onmouseup();
				this.update();
			}
		}

		while (sel) {
			var t = dn.slider.style.top ? parseInt(dn.slider.style.top, 10) : 0;
			if (t + sel.offsetTop + sel.offsetHeight < dn.container.offsetHeight) {
				ajax.send('toolbar.php?top='+dn.slider.offsetTop,'');
				break;
			}
			dn.scroll();
		}

		this.update();
	}

	this.scroll = function(b) {
		b.timer = setInterval(function() { b.scroll(); }, 100);
		b.scroll();
	}

	this.toggle = function() {
		var tb = $(id);
		var handler = $(id+'Handler');
		var display = '';
		var visibility = 'visible';
		if (handler.title == 'Collapse') {
			handler.title = 'Expand';
			handler.src = 'images/expand.gif';
			display = 'none';
			visibility = 'hidden';
			ajax.send('toolbar.php?status=off','');
		}
		else {
			handler.title = 'Collapse';
			handler.src = 'images/collapse.gif';
			ajax.send('toolbar.php?status=on','');
		}
		for (var i = 0; i < tb.rows.length; i++) {
			var c = tb.rows[i].cells[0];
			c.style.display = display;
			c.style.visibility = visibility;
		}
		tb.rows[0].cells[1].style.display = display;
		tb.rows[0].cells[1].style.visibility = visibility;

		Contents.resize();
	}

	this.update = function() {
		var up = $(id+'Up');
		var dn = $(id+'Dn');
		if (up.update) up.update();
		if (dn.update) dn.update();
	}

	return this;
}
